<template>
  <el-image
          :src="src"
          :preview-src-list="srcList"
          :initial-index="srcList.indexOf(getBaseImageUrl(row))"
          lazy
  />
</template>

<script>
  import {computed} from 'vue'
  import {getBaseImageUrl} from "@/utils/reviewimage";

  export default {
    name: "EImage",
    props: {
      row: {
        type: Object,
        required: true
      },
      srcList: {
        type: Array,
        required: true
      },
      width: {
        type: Number
      },
      height: {
        type: Number
      }
    },
    setup(props) {
      const src = computed(() => {
        let imgsrc = getBaseImageUrl(props.row)
        if (props.row.isself) {
          if (props.width) {
            imgsrc += '&width=' + props.width
          }
          if (props.height) {
            imgsrc += '&height=' + props.height
          }
        }
        return imgsrc
      })
      return {
        src,
        getBaseImageUrl
      }
    }
  }
</script>

<style scoped>

</style>
